import {Col, Row} from 'antd'
import React, {Component, Suspense} from 'react'
import {connect} from 'umi'
import {getDoToEvent, getMainInfo, getPreInfo, getNotice} from './service'
import './index.less'

import AppsPortal from './components/AppsPortal'
import TodoPortal from './components/TodoPortal'
import BannerPortal from './components/BannerPortal'
import MileagePortal from './components/MileagePortal'
import HonorPortal from './components/HonorPortal'


class Workplace extends Component {
  state = {
    mainInfo: {},
    preInfo: {},
    upcomingList: [],
    noticeList: []
  };

  componentDidMount() {
    // getMainInfo().then(res => {
    //   this.setState({mainInfo: res});
    // });
    // getPreInfo().then(res => {
    //   this.setState({preInfo: res});
    // });
    // getDoToEvent().then(res => {
    //   this.setState({upcomingList: res ? res : []});
    // });
    getNotice().then((res = {}) => {
      this.setState({noticeList: res.list ? res.list : []});
    });
  }

  render() {
    const {loading,currentUser} = this.props;
    return (
      <div>
        <Row gutter={24} style={{marginBottom: 24}}>
          <Col span={24}>
            <BannerPortal currentUser={currentUser}/>
          </Col>
        </Row>

        {/*<Row gutter={24} style={{marginBottom: 24}}>*/}
        {/*  <Col span={24}>*/}
        {/*    <HonorPortal />*/}
        {/*  </Col>*/}
        {/*</Row>*/}

        <Row gutter={24} style={{marginBottom: 24}}>
          <Col xl={24} lg={24} md={24} sm={24} xs={24}>
            <Suspense fallback={null}>
              <TodoPortal loading={loading} noticeList={this.state.noticeList}/>
            </Suspense>
          </Col>
          {/*<Col xl={12} lg={12} md={12} sm={12} xs={12}>*/}
          {/*  <Suspense fallback={null}>*/}
          {/*    <TodoPortal loading={loading} noticeList={this.state.noticeList}/>*/}
          {/*  </Suspense>*/}
          {/*</Col>*/}
          {/*<Col style={{flex: 1}}>*/}
          {/*  <Suspense fallback={null}>*/}
          {/*    <MileagePortal loading={loading} day={32}/>*/}
          {/*  </Suspense>*/}
          {/*</Col>*/}
        </Row>

        <Row gutter={24} style={{marginBottom: 24}}>
          <Col span={24}>
            <Suspense fallback={null}>
              <AppsPortal router={history} loading={loading}/>
            </Suspense>
          </Col>
        </Row>
      </div>
    )
  }
}

export default connect(({workplace, loading,user}) => ({
  workplace,
  loading: loading.effects['workplace/fetch'],
  currentUser: user?.currentUser
}))(Workplace)
